package cn.flyboy.mapper;

import java.util.List;
import java.util.Set;

import cn.flyboy.entity.Teacher;
import org.apache.ibatis.annotations.*;

public interface TeacherMapper {
    @Select("select * from teacher where t_username=#{t_username} and t_pwd=#{t_pwd} and t_manager=#{t_manager}")
    Teacher selByTeacher(Teacher teacher);

    @Select("select * from teacher where t_manager=1")
    List<Teacher> selByManager();

    @Select("select * from teacher")
    List<Teacher> selAllTeacher();

    @Select("select count(*) from teacher where t_username=#{param1}")
    int selTeaNumOfId(String userID);

    @Select("select * from teacher where t_username=#{param1}")
    Teacher selTeacher(String userID);

    @Insert("insert into teacher value(#{t_username},#{t_pwd},#{t_name},#{t_manager})")
    void insTeacher(Teacher teacher);

    @Update("update teacher set t_pwd=#{t_pwd} where t_username=#{t_username}")
    int updPwd(Teacher teacher);

    @Update("update teacher set t_name=#{t_name},t_manager=#{t_manager} where t_username=#{t_username}")
    int updTeacher(Teacher teacher);

    @Delete("delete from teacher where t_username=#{t_name}")
    int delTeacher(String t_name);

    @Delete("<script>" + "delete from teacher where t_username in " +
            "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
            "#{item}" + "</foreach>" + "</script>")
    @Results(value = {@Result(column = "id", property = "id")})
    int deleteTeacherBatch(@Param("ids") Set<String> ids);

}
